<template>
  <div v-loading="loading" class="login-container">

    <el-dialog
      title="检测结果："
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose">

      <div v-if="checkresult">
        <div class="titletxt">血贫：{{checkresult.hb == true ? "是":"否"}}</div>
        <div class="titletxt">血栓：{{checkresult.plt == true ? "是":"否"}}</div>
        <div class="titletxt">淋巴细胞增多症：{{checkresult.ly == true ? "是":"否"}}</div>
        <div class="titletxt">单核细胞性白血病：{{checkresult.mono == true ? "是":"否"}}</div>
        <div class="titletxt">转氨酶过多时肝病：{{checkresult.zam == true ? "是":"否"}}</div>
        <div class="titletxt">癌症：{{checkresult.apky == true ? "是":"否"}}</div>
        <div class="titletxt">肾病：{{checkresult.ns == true ? "是":"否"}}</div>
        <div class="titletxt">糖尿病：{{checkresult.xt == true ? "是":"否"}}</div>
        <div class="titletxt">高血压：{{checkresult.xy == true ? "是":"否"}}</div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
      </span>
    </el-dialog>
    <el-row v-if="avaleable==false" class="wscn-http404" :gutter="20">
      <el-col class="pic-404" :span="10">
        <img src="../../../assets/images/loadding.gif">
      </el-col>
      <el-col class="bullshit" :span="10">
        <div class="bullshit__oops">抱歉!</div>
        <div class="bullshit__info">您不是检测科医生</div>
        <div class="bullshit__headline">{{ message }}</div>
        <span @click="gomain" class="bullshit__return-home">查看疫情分布</span>
      </el-col>
    </el-row>
    <el-row v-else>
      <el-col :span="10">
        <el-card style="margin-top: 30px;border: 1px solid #1fac1a">

          <div slot="header" class="clearfix">
            <span>用户信息：</span>
          </div>
          <div>
            <svg-icon style="font-size: 120px;color: green" icon-class="user"></svg-icon>
          </div>
          <el-form>
            <el-form-item label="名称：">
              {{userinfo.realname ? userinfo.realname:"...."}}

            </el-form-item>
            <el-form-item label="性别：">
              {{userinfo.gender != undefined ? (userinfo.gender == true ? "男性":"女性") :"...."}}
            </el-form-item>
            <el-form-item label="年龄：">
              {{userinfo.age ? userinfo.age:"...."}}
            </el-form-item>
            <el-form-item label="身份证：">
              {{userinfo.idcard ? userinfo.idcard:"...."}}
            </el-form-item>
            <el-form-item label="14天到访城市：">
              <div v-if="userinfo.citys" v-for="(item,index) in userinfo.citys">
                <el-cascader
                  :options="citylist"
                  v-model="item.city"
                  expand-trigger="hover"
                >
                </el-cascader>
              </div>
              <span v-else>....</span>
            </el-form-item>

            <el-form-item label="检测状态：">
              {{userinfo.checked != undefined ? (userinfo.checked == true ? "已检测":"未检测"):"...."}}
            </el-form-item>
          </el-form>
        </el-card>

      </el-col>
      <el-col v-if="userinfo.realname" :offset="1" :span="11">
        <el-card style="margin-top: 30px;border: 1px solid #1fac1a">

          <div slot="header" class="clearfix">
            <span>血常规信息录入：</span>
          </div>
          <el-form ref="form" :model="userchecklist" label-width="120px">

            <el-form-item label="红细胞计数：">
              <el-input type="number" v-model="userchecklist.rbc" placeholder="（参考值：3.5~5.5），（单位：10^12/L）"></el-input>

            </el-form-item>
            <el-form-item label="血红蛋白浓度：">
              <el-input type="number" v-model="userchecklist.hb" placeholder="（参考值：120~160），（单位：g/L）"></el-input>
            </el-form-item>
            <el-form-item label="血小板计数：">
              <el-input type="number" v-model="userchecklist.plt" placeholder="(参考值：100~300），（单位：10^9/L）"></el-input>
            </el-form-item>
            <el-form-item label="淋巴细胞比值：">
              <el-input type="number" v-model="userchecklist.ly" placeholder="（参考值：17~48），（单位：%）"></el-input>
            </el-form-item>
            <el-form-item label="单核细胞计数：">
              <el-input type="number" v-model="userchecklist.mono" placeholder="（参考值：0.3~0.8），（单位：10^9/L）"></el-input>
            </el-form-item>
            <el-form-item label="转氨酶：">
              <el-input type="number" v-model="userchecklist.zam" placeholder="(参考值：0-40U/L)"></el-input>
            </el-form-item>
            <el-form-item label="癌胚抗原：">
              <el-input type="number" v-model="userchecklist.apky" placeholder="(参考值：0-5）"></el-input>
            </el-form-item>
            <el-form-item label="尿酸：">
              <el-input type="number" v-model="userchecklist.ns" placeholder="（参考值：男生(149-416)、女生：89-357） "></el-input>
            </el-form-item>
            <el-form-item label="血糖：">
              <el-input type="number" v-model="userchecklist.xt" placeholder="（参考值：3.9-6.1）"></el-input>
            </el-form-item>
            <el-form-item label="血压：">
              <el-input type="number" v-model="userchecklist.xy" placeholder="（参考值：90-140） "></el-input>
            </el-form-item>
            <el-form-item label="操作：">
              <el-button @click="gopredict" size="mini" type="success">预测</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </el-col>
    </el-row>
    <el-row style="margin-top: 30px">
      <el-col :offset="5" :span="5">

        <el-button @click="getnextUser" type="success">分配下一位用户</el-button>
      </el-col>
    </el-row>

    <el-row style="margin-top: 30px">
      <div class="titletxt">
        操作小Tips:
      </div>
      <div class="infotxt">
        点击分配下一步用户按钮后，自动分配用户给您
      </div>
      <div class="infotxt">
        您输入该用户的血常规后，点击预测疾病按钮，系统会使用人工智能算法进行疾病预测
      </div>

    </el-row>
  </div>
</template>

<script>
  import {updateMyInfo, getUnCheckUser, getUserBaseInfo, getlastSpiderlog, reportUserHealth} from '@/api/doctor'
  import {getToken, setToken, removeToken} from '@/utils/auth'
  import {regionData} from "element-china-area-data";

  export default {
    name: 'login',
    data() {
      return {
        value: new Date(), // 当前月份
        qiandaolist: [],
        userinfo: {},
        userchecklist: {},
        myinfo: undefined,
        checkresult:undefined,
        dialogVisible: false,
        loading: false,
        citylist: regionData,
        avaleable: false,
        formLabelAlign: {},
        yiqingdata: undefined,
      }
    },
    created() {
      this.getBaseInfo()
    },

    computed: {
      message() {
        return '本功能模块需要医生为检测科医生才可使用 ......'
      }
    },
    watch: {
      value: function () {

      }
    },
    methods: {
      gopredict() {
        this.loading = true;
        this.userchecklist.uid = this.userinfo.id;
        reportUserHealth(this.userchecklist).then(res => {
          this.checkresult = res.info
          this.dialogVisible =true;
          this.loading = false;
          console.log(res)
        }).catch(err=>{
          this.loading = false;
        })
      },
      getnextUser() {
        this.loading = true;
        getUnCheckUser({}).then(res => {
          console.log(res);
          if (res.code == 0) {
            this.$notify({type: "error", message: "暂无待检测用户！", title: "稍等"})
          }
          this.loading = false;
          res.info.citys = JSON.parse(res.info.citys)
          this.userinfo = res.info;
        }).catch(err => {
          this.loading = false;
          console.log("err")
          console.log(err)
          // if(err.code != 1)
          //   this.$notify({type:"error",message:"无待检测用户！",title:"暂无"})
        })
      },
      handleClose(done) {
        this.dialogVisible = false;
      },
      gomain() {
        this.$router.push({path: "/doctor"});
      },
      getBaseInfo() {
        getUserBaseInfo({}).then(res => {
          this.loading = false;
          this.formLabelAlign = res.info
          if (res.info.subject.indexOf("检测") || res.info.subject.indexOf('检查')) {
            this.avaleable = true;
          }
        })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .clearfix {
    font-size: x-large;
    color: #454545;
  }

  .checkitem {
    margin-top: 10px;
    font-size: medium;
    font-weight: normal;

  }

  .wscn-http404 {
    position: relative;
    width: 1200px;
    margin: 20px auto 60px;
    padding: 0 100px;
    overflow: hidden;

    .pic-404 {
      position: relative;
      float: left;
      width: 600px;
      padding: 150px 0;
      overflow: hidden;

      &__parent {
        width: 100%;
      }

      &__child {
        position: absolute;

        &.left {
          width: 80px;
          top: 17px;
          left: 220px;
          opacity: 0;
          animation-name: cloudLeft;
          animation-duration: 2s;
          animation-timing-function: linear;
          animation-fill-mode: forwards;
          animation-delay: 1s;
        }

        &.mid {
          width: 46px;
          top: 10px;
          left: 420px;
          opacity: 0;
          animation-name: cloudMid;
          animation-duration: 2s;
          animation-timing-function: linear;
          animation-fill-mode: forwards;
          animation-delay: 1.2s;
        }

        &.right {
          width: 62px;
          top: 100px;
          left: 500px;
          opacity: 0;
          animation-name: cloudRight;
          animation-duration: 2s;
          animation-timing-function: linear;
          animation-fill-mode: forwards;
          animation-delay: 1s;
        }

        @keyframes cloudLeft {
          0% {
            top: 17px;
            left: 220px;
            opacity: 0;
          }
          20% {
            top: 33px;
            left: 188px;
            opacity: 1;
          }
          80% {
            top: 81px;
            left: 92px;
            opacity: 1;
          }
          100% {
            top: 97px;
            left: 60px;
            opacity: 0;
          }
        }
        @keyframes cloudMid {
          0% {
            top: 10px;
            left: 420px;
            opacity: 0;
          }
          20% {
            top: 40px;
            left: 360px;
            opacity: 1;
          }
          70% {
            top: 130px;
            left: 180px;
            opacity: 1;
          }
          100% {
            top: 160px;
            left: 120px;
            opacity: 0;
          }
        }
        @keyframes cloudRight {
          0% {
            top: 100px;
            left: 500px;
            opacity: 0;
          }
          20% {
            top: 120px;
            left: 460px;
            opacity: 1;
          }
          80% {
            top: 180px;
            left: 340px;
            opacity: 1;
          }
          100% {
            top: 200px;
            left: 300px;
            opacity: 0;
          }
        }
      }
    }

    .bullshit {
      position: relative;
      float: left;
      width: 300px;
      padding: 150px 0;
      overflow: hidden;

      &__oops {
        font-size: 32px;
        font-weight: bold;
        line-height: 40px;
        color: #1482f0;
        opacity: 0;
        margin-bottom: 20px;
        animation-name: slideUp;
        animation-duration: 0.5s;
        animation-fill-mode: forwards;
      }

      &__headline {
        font-size: 20px;
        line-height: 24px;
        color: #1482f0;
        opacity: 0;
        margin-bottom: 10px;
        animation-name: slideUp;
        animation-duration: 0.5s;
        animation-delay: 0.1s;
        animation-fill-mode: forwards;
      }

      &__info {
        font-size: 13px;
        line-height: 21px;
        color: grey;
        opacity: 0;
        margin-bottom: 30px;
        animation-name: slideUp;
        animation-duration: 0.5s;
        animation-delay: 0.2s;
        animation-fill-mode: forwards;
      }

      &__return-home {
        display: block;
        float: left;
        width: 110px;
        height: 36px;
        background: #1482f0;
        border-radius: 100px;
        text-align: center;
        color: #ffffff;
        opacity: 0;
        font-size: 14px;
        line-height: 36px;
        cursor: pointer;
        animation-name: slideUp;
        animation-duration: 0.5s;
        animation-delay: 0.3s;
        animation-fill-mode: forwards;
      }

      @keyframes slideUp {
        0% {
          transform: translateY(60px);
          opacity: 0;
        }
        100% {
          transform: translateY(0);
          opacity: 1;
        }
      }
    }
  }

  .titletxt {
    font-size: x-large;
    color: #454545;
    margin-bottom: 20px;
  }

  .infotxt {
    font-size: medium;
    color: #454545;
    margin: 10px;
  }

</style>
